/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.interaction3d.assembly.convert.collada;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author micha
 */
class Coordinates
{
    private final Map<String, Integer> sourceOffsets = new HashMap<String, Integer>();
    private final List<double[]> coordinates = new ArrayList<double[]>();

    public double[][] elements()
    {
        return coordinates.toArray(new double[coordinates.size()][]);
    }

    public int offset(String source, double[]... data)
    {
        if(sourceOffsets.containsKey(source))
        {
            throw new IllegalArgumentException("Already contains: " + source);
        }

        int offset = coordinates.size();
        this.coordinates.addAll(Arrays.asList(data));
        sourceOffsets.put(source, offset);
        return offset;
    }

    public Integer offset(String source)
    {
        return sourceOffsets.get(source);
    }
}
